{% import "macros/utilities/standard.html" as standard %}


{%- macro meta_tags(page) -%}
  <meta name="author" content="{{ config.extra.author | safe }}">
  {%- if page.description -%}
    <meta name="description" content="{{ page.description | safe }}" />
  {%- endif -%}

  {%- if page.date -%}
    <meta property="article:published_time" content='{{ page.date | safe }}' />
  {%- endif -%}

  {%- if page.updated -%}
    <meta property="article:modified_time" content='{{ page.updated | safe }}' />
  {%- endif -%}
  
  {%- if page.taxonomies.tags -%}
    <meta name="keywords" content="
      {%- for tag in page.taxonomies.tags -%}
        {{ tag | safe }}, 
      {%- endfor -%}
    ">
  {%- endif -%}
  
  <meta name="generator" content="Zola">
{%- endmacro meta_tags -%}


{%- macro open_graph(page) -%}
  <meta property="og:title" content="{{ page.title | safe }}" />
  <meta property="og:url" content="{{ page.permalink | safe }}" />
  {%- if page.description -%}
    <meta property="og:description" content="{{ page.description | safe }}" />
  {%- endif -%}
  {%- if page.extra.image -%}
    <meta property="og:image" content="{{ standard::get_url_on_location(path = page.extra.image.path) }}" />
  {%- endif -%}
  <meta property="og:site_name" content="{{ config.title | safe }}" />
  <meta property="og:locale" content="{{ config.extra.locale | safe }}" />
{%- endmacro open_graph -%}


{%- macro twitter_cards() -%}
  <meta name="twitter:card" content="summary" />
  {%- if config.extra.social.twitter -%}
    <meta name="twitter:creator" content="{{ config.extra.social.twitter | safe }}" />
  {%- endif -%}
{%- endmacro twitter_cards -%}


{%- macro google_search_console() -%}
  {%- if config.extra.seo.google_search_console -%}
    <meta name="google-site-verification" content="{{ config.extra.seo.google_search_console | safe }}" />
  {%- endif -%}
{%- endmacro google_search_console -%}


{%- macro google_analytics() -%}
  {%- if config.extra.seo.google_analytics -%}
    <script async src="https://www.googletagmanager.com/gtag/js?id={{ config.extra.seo.google_analytics | safe }}"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', '{{ config.extra.seo.google_analytics | safe }}');
    </script>
  {%- endif -%}
{%- endmacro google_analytics -%}
